package com.zwj.grpcspringcloudprovider;

import com.zwj.grpc.cloud.lib.HelloReply;
import com.zwj.grpc.cloud.lib.HelloRequest;
import com.zwj.grpc.cloud.lib.SimpleGrpc;
import lombok.extern.slf4j.Slf4j;
import net.devh.boot.grpc.server.service.GrpcService;


import java.util.Date;

/**
 * 简单方式服务
 */
@Slf4j
@GrpcService
public class SimpleGreeterService extends SimpleGrpc.SimpleImplBase {
    @Override
    public void sayHello(HelloRequest request,
                         io.grpc.stub.StreamObserver<HelloReply> responseObserver) {
        HelloReply reply = HelloReply.newBuilder().setMessage("Hello " + request.getName() + ", " + new Date()).build();
        responseObserver.onNext(reply);
        responseObserver.onCompleted();
    }
}